<tagLib name="html" />
<script type="text/javascript">
	function add_serve_record() {
		$("#form_serve_record :input :not(:button) :not('select')").each(function() {
			$(this).val("");
		});
		$("#form_serve_record :text").each(function() {
			$(this).val("");
		});
		$("#form_serve_record select").each(function() {
			$(this).find('option:first').attr('selected', 'selected');
		});
		$(".serve_record_sub_left_menu tr.active").removeClass("active");
		$("#serve_record_opmode").val("add");
	}

	function save_serve_record() {
		if(check_form("form_serve_record")){
      sendForm("form_serve_record", "{:U('serve_record/save')}",window.location.href);
		}		
	}

  function destroy_serve_record() {
    var id = $(".serve_record_sub_left_menu  tr.active").attr('id');
    if(id==undefined){
      alert('请先选择联系记录');
      return false;
    }
    sendAjax("{:U('serve_record/del')}", "id=" + id, function(data) {
        if(data['status']=='1'){
          alert(data['info']);
        }else{
          alert('未成功！'); 
        };
       location.reload();
    });
  }

	function showdata(result) {
		for (var s in result.data) {
			set_val(s,result.data[s]);
		}
    $("#contact_result_id_"+result.data['contact_result_id']).click(); 
    $("#content").text(result.data['content']); 
		$("#save_name").val("");
		$("#opmode").val("edit");
	}

	$(document).ready(function(){		
	//	$(".input-date").datepicker();
		$("#serve_record_content").on('click',"tr",function() {
			$(".serve_record_sub_left_menu  tr.active").removeClass("active");
      $('#serve_record_opmode').val('edit');
      $('#serve_record_id').val($(this).attr('id'));
			$(this).attr("class","active");
      //alert($(this).html());
			sendAjax("{:U('serve_record/read')}", "id=" + $(this).attr("id"), function(data) {
        //alert(data);
				showdata(data);
			});
			return false;
		})
	});

</script>
<div class="admin" >
	<form method="post" action="" id="form_search" name="form_search">
		<div class="row-fluid title">
      <a href="javascript:void($('#serve_record').toggle())">
        <span>服务小计管理</span>
      </a>
		</div>
	</form>
  <div id="serve_record" style="display:none;">
	<div class="row-fluid operate" >
		<div class="right">
			<a onclick="add_serve_record()"  class="btn">新增</a>
			<a onclick="save_serve_record()"  class="btn">保存</a>
			<a onclick="destroy_serve_record()"  class="btn">删除</a>
		</div>
	</div>
	<div class="row-fluid">
		<div class="span4 serve_record_sub_left_menu ">
			<table class="table table-bordered">
				<tr id="serve_tr">
					<th>联系时间</th>
					<th>联系人</th>
					<th>客服</th>
				</tr>
        <tr>
          <td colspan=3 id="serve_record_content"> 
            <include file="serve_record_ajaxlist" />
          </td>
          <tr>
			</table>
		</div>
		<div class="span8">
			<form id="form_serve_record" name="form_serve_record" method="post" action="">
				<input type="hidden" id="save_name" name="save_name">
				<input type="hidden" name="id" id="serve_record_id">
				<input type="hidden" name="pid" id="serve_record_pid" value="">
        <input type="hidden" name="mini_client_id" id="serve_record_mini_client_id" value="{$vo.id}">
				<!--<input type="hidden" name="pic" id="serve_record_pic" >-->
				<input type="hidden" name="ajax" id="serve_record_ajax" value="1">
				<input type="hidden" name="opmode" id="serve_record_opmode" value="">
				<!--<input type="hidden" name="created_user_id" id="serve_record_created_user_id" value="">-->
				<!--<html:select id="dept_list" name="dept_list"  options="dept_list" style="dis"/>-->
				<table class="table table-bordered" >
					<tr>
						<th>联系人*</th>
            <?php 
            foreach ($lianxiren_list as $lxr ) {
              $lianxiren_select_list[$lxr['id']] = $lxr['name'];
            }
           // print_r($lianxiren_select_list);
            //print_r($contact_way_list);
            ?>
						<td>
              <html:select id="contact_person_id" name="contact_person_id"  options="lianxiren_select_list" style="input-small"/>
              <!--<input type="text" id="name" name="name" class="input-small" check="require" msg="请输入姓名">-->
            </td>
						<th>服务方式</th>
						<td>
              <html:select id="contact_way_id" name="contact_way_id"  options="serve_way_list" style="input-small"/>
						</td>
					</tr>
					<tr class='' style=";">
						<th>关联的订单</th>
						<td colspan=3>
              <html:select id="order_id" name="order_id"  options="order_select_list" style="input-small"/>
						</td>
					</tr>
					<tr>
						<th>联系结果*</th>
						<td colspan=3>
              <span class="span6">
                有效的联系：<input id="contact_result_id_1" checked="checked" type="radio" value="1" onclick="$('.youxiao').show();$('.wuxiao').hide();" name="contact_result_id">
              </span>
              <span class="span6">
                无效的联系:<input id="contact_result_id_0" type="radio" value="0" onclick="$('.youxiao').hide();$('.wuxiao').show();" name="contact_result_id">
              </span>
            </td>
					</tr>
					<tr class='youxiao' style=";">
						<th>服务内容</th>
						<td colspan=3>
              <textarea rows=5 id="content" name="content" class="span12"></textarea>
              <!--<input type="textarea" rows=3 id="content" name="content" class="span12">-->
						</td>
					</tr>
					<tr class="wuxiao" style="display:none;">
						<th>联系备注</th>
						<td colspan="3">
              <input type="text" name="invalid_contact_description" id="invalid_contact_description" class="span12">
						</td>
						</td>
					</tr>
				</table>
			</form>
		</div>
    <!--<div class="page">-->
      <!--{$page}-->
    <!--</div>-->
	</div>
</div>
</div>
